<?php

/**

 * Created by PhpStorm.

 * User: Administrator

 * Date: 2019/9/3

 * Time: 10:15

 */



namespace app\currency\controller;

use library\Controller;

use think\Console;

use think\Db;



class Ad extends Controller

{

    /**

     * 广告轮播表

     * @var string

     */

    protected $table = 'Ad';



    /**

     * 广告轮播管理

     * @menu true

     * @auth true

     * @throws \think\Exception

     * @throws \think\db\exception\DataNotFoundException

     * @throws \think\db\exception\ModelNotFoundException

     * @throws \think\exception\DbException

     * @throws \think\exception\PDOException

     */

    public function index()

    {

        $this->title = '广告轮播管理';

        $this->_query($this->table)->equal('status')->like('title')->where(['is_deleted' => '0'])->order('sort desc,id desc')->page();

    }

    /**

     * 添加广告信息

     * @auth true

     * @throws \think\Exception

     * @throws \think\db\exception\DataNotFoundException

     * @throws \think\db\exception\ModelNotFoundException

     * @throws \think\exception\DbException

     * @throws \think\exception\PDOException

     */

    public function add()

    {

        $this->_form($this->table, 'form');

    }



    /**

     * 编辑广告信息

     * @auth true

     * @throws \think\Exception

     * @throws \think\db\exception\DataNotFoundException

     * @throws \think\db\exception\ModelNotFoundException

     * @throws \think\exception\DbException

     * @throws \think\exception\PDOException

     */

    public function edit()

    {

        $this->_form($this->table, 'form');

    }


    /**
     * 禁用
     * @auth true
     * @throws \think\Exception
     * @throws \think\exception\PDOException
     */

    public function forbid()

    {

        $this->_save($this->table, ['status' => '0']);

    }


    /**
     * 启用
     * @auth true
     * @throws \think\Exception
     * @throws \think\exception\PDOException
     */

    public function resume()

    {

        $this->_save($this->table, ['status' => '1']);

    }


    /**
     * 删除
     * @auth true
     * @throws \think\Exception
     * @throws \think\exception\PDOException
     */

    public function remove()

    {

        $this->_delete($this->table);

    }



}